﻿
using System.Collections.ObjectModel;
namespace NextUIKit.Data
{
    public class SlideViewItems
    {
        #region Fields
        private ObservableCollection<string> _urls;
        private const int _groupCount = 3;
        private int _showIndex;
        #endregion

        #region Constructor
        public SlideViewItems(ObservableCollection<string> urls,int showIndex) 
        {
            this.Urls = urls;
            this._showIndex = showIndex;
        }
        #endregion

        #region Properties
        public ObservableCollection<string> Urls
        {
            get { return _urls; }
            set { _urls = value; }
        }

        public int ShowIndex
        {
            get { return _showIndex; }
            set { _showIndex = value; }
        }
        #endregion

        #region Method
        public string PreUrl
        {
            get
            {
                if (_showIndex - 1 < 0)
                {
                    return _urls[UrlsCount - 1];
                }
                else
                {
                    return _urls[_showIndex - 1];
                }
            }
        }

        public string CurUrl
        {
            get
            {
                return _urls[_showIndex];
            }
        }

        public string NextUrl
        {
            get
            {
                if (_showIndex + 1 >= UrlsCount)
                {
                    return _urls[0];
                }
                else
                {
                    return _urls[_showIndex + 1];
                }
            }
        }

        public int UrlsCount
        {
            get
            {
                return _urls.Count;
            }
        }
        #endregion

        #region Method
        public void MoveToNext()
        {
            _showIndex += 1;
            if (_showIndex>= UrlsCount)
            {
                _showIndex = 0;
            }
        }

        public void MoveToPre()
        {
            _showIndex -= 1;
            if (_showIndex < 0)
            {
                _showIndex = UrlsCount - 1;
            }
        }
        #endregion
    }
}
